Skip to content

BUG: stop dict_generator from sampling initial_solution (#1109) - #1122

Merged
Gui-FernandesBR merged 1 commit into
RocketPy-Team:developfrom
thatrandomasiandev:bug/1109-dict-generator-initial-solution
Aug 15, 2026
Merged

BUG: stop dict_generator from sampling initial_solution (#1109)#1122
Gui-FernandesBR merged 1 commit into
RocketPy-Team:developfrom
thatrandomasiandev:bug/1109-dict-generator-initial-solution

Conversation

@thatrandomasiandev

Copy link
Copy Markdown

Pull request type

  • Code changes (bug fix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/ / make lint) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md — no action needed; an LLM workflow auto-updates it after merge

Current behavior

StochasticModel.dict_generator treated every instance tuple/list as a stochastic input, so a 14-tuple initial_solution crashed ('float' object is not callable) and list form silently sampled one element.

Fixes #1109

New behavior

dict_generator samples only declared constructor stochastic inputs. StochasticFlight validates initial_solution on construct and never puts it in the generated dict.

Breaking change

  • No

Additional information

Focused unit tests added/extended; full slow suite not run in this contribution pass.

@thatrandomasiandev
thatrandomasiandev requested a review from a team as a code owner August 11, 2026 01:22
@ting-hong-shieh

Copy link
Copy Markdown

I checked head 9cc93a1c82bf1d1c12fb0e8d933ef12cecc37540 against the behavior described in #1109.

  • A 14-element tuple remains byte-for-byte equal to the supplied initial_solution and is absent from the dictionary returned by dict_generator().
  • A 14-element list also remains unchanged and is absent from the generated dictionary; a declared stochastic list such as inclination=[85, 86, 87] is still sampled normally.
  • pytest tests/unit/stochastic/test_stochastic_flight.py -q5 passed.

This validates both supported initial_solution forms without broadening the exclusion to declared stochastic constructor inputs. No branch changes were made.

Environment: Python 3.12.6; NumPy 2.5.2; pytest 9.1.1; macOS 26.5.2 arm64. Current develop: cb6106a717207dd8fc2dfe1446d80ff75022f21b.

@Gui-FernandesBR
Gui-FernandesBR force-pushed the bug/1109-dict-generator-initial-solution branch from 9cc93a1 to fce9756 Compare August 14, 2026 09:40
@Gui-FernandesBR

Copy link
Copy Markdown
Member

I checked head 9cc93a1c82bf1d1c12fb0e8d933ef12cecc37540 against the behavior described in #1109.

  • A 14-element tuple remains byte-for-byte equal to the supplied initial_solution and is absent from the dictionary returned by dict_generator().
  • A 14-element list also remains unchanged and is absent from the generated dictionary; a declared stochastic list such as inclination=[85, 86, 87] is still sampled normally.
  • pytest tests/unit/stochastic/test_stochastic_flight.py -q5 passed.

This validates both supported initial_solution forms without broadening the exclusion to declared stochastic constructor inputs. No branch changes were made.

Environment: Python 3.12.6; NumPy 2.5.2; pytest 9.1.1; macOS 26.5.2 arm64. Current develop: cb6106a717207dd8fc2dfe1446d80ff75022f21b.

@ting-hong-shieh so in your opinion, should we proceed with this PR?

@Gui-FernandesBR Gui-FernandesBR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see anything weird with this...

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.53%. Comparing base (e0ff281) to head (dcc8c06).
⚠️ Report is 64 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1122      +/-   ##
===========================================
+ Coverage    82.18%   83.53%   +1.35%     
===========================================
  Files          122      130       +8     
  Lines        16355    17086     +731     
===========================================
+ Hits         13441    14273     +832     
+ Misses        2914     2813     -101     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ting-hong-shieh

Copy link
Copy Markdown

Based on what I verified at 9cc93a1, yes, I think this PR should proceed. The fix keeps initial_solution out of dict_generator() while preserving sampling for declared stochastic inputs.

The current head is now fce9756, so my local verification does not cover that exact revision. Tests and linters are green, but the Documentation check is currently failing; I would wait for that check to be resolved before merging.

…m#1109)

Generate stochastic samples from declared constructor inputs only, and
validate StochasticFlight.initial_solution on construct.
@Gui-FernandesBR
Gui-FernandesBR force-pushed the bug/1109-dict-generator-initial-solution branch from fce9756 to dcc8c06 Compare August 15, 2026 01:38
@Gui-FernandesBR
Gui-FernandesBR merged commit 5a71eb9 into RocketPy-Team:develop Aug 15, 2026
7 of 8 checks passed
Gui-FernandesBR added a commit that referenced this pull request Aug 15, 2026
The nested a./b. list was indented deeper than the body of item 1 with no
blank line in between, which docutils reports as "Unexpected indentation".
Since #1122 landed this broke `build-docs` for every pull request opened
against develop, including PRs that do not touch this file.

Aligns the sublist with the parent item's body, adds the required blank
line, and drops the now-unneeded line continuations.
thc1006 added a commit to thc1006/RocketPy that referenced this pull request Aug 15, 2026
RocketPy-Team#1122 made dict_generator walk the declared stochastic inputs rather than the
whole instance, which is the right fix for RocketPy-Team#1109 and makes the collection-skip
this branch carried redundant. add_cp_eccentricity and add_thrust_eccentricity
run after __init__ has already built that list, so their values stopped being
sampled: four eccentricities became none.

They are declared as they are validated now. The component_collections
mechanism is gone, since walking the declared inputs never saw the collections
in the first place.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Gui-FernandesBR pushed a commit that referenced this pull request Aug 15, 2026
)

#1122 made dict_generator walk the inputs a model declared instead of every
attribute on it, which is the right shape for #1109. add_cp_eccentricity and
add_thrust_eccentricity run after __init__ has built that list, so their
distributions stopped being drawn from: the value was set on the instance and
every simulation used the same one, with nothing to say so.

Bisected: at 3e16c9f all four eccentricities appear in the generated
dictionary, at 5a71eb9 none of them do.

An add_* method now declares what it installed, with the argument as given
rather than the validated form, so _set_stochastic validates it again on each
reseed and binds the distribution to the generator that is live then.
ensemble_member was already fine, since StochasticEnvironment passes it through
the constructor and the hasattr guard covers it not being set yet.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants